using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Park.Net.Model;
using Park.Net.EFCoreEnv;
using Park.Net.IRepository;
using Park.Net.Repository;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;


namespace Park.Net.IRepository
{
    public class  FeedbackRepository : BaseRepository<Feedback>, IFeedbackRepository
    {
         private readonly ParkDbContext  _context;

        public FeedbackRepository(ParkDbContext db) : base(db)
        {
            ParkDb = db;
            _context=db;
        }


         public async override Task<List<Feedback>> FindAllAsync()
        {
            return await _context.Feedback.ToListAsync();
        }

        public async override Task<List<Feedback>> FindManyAsync(Expression<Func<Feedback, bool>> exp)
        {
            return await _context.Feedback.Where(exp).ToListAsync();
        }

        public async override Task<Feedback> FindOneAsync(Expression<Func<Feedback, bool>> exp)
        {
            return await _context.Feedback.FirstOrDefaultAsync(exp);
        }

        public override async Task<Feedback> FindOneAsync(int id)
        {
            return await _context.Feedback.FirstOrDefaultAsync(art=>art.ID == id);
        }
    }
}
